package online.inote.modules.error.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * <p>
 * Desc: 
 * </p>
 *
 * @author XQF SUI
 * @created 2018年8月26日 上午11:28:27
 * @version 1.0
 */
@Controller
@RequestMapping(value = "error")
public class ErrorController {

	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@RequestMapping(value = "errorPage/{code}")
	public String errorPage(@PathVariable("code") int code) {
		logger.info("跳转到错误页面, 状态码:[ {} ]", code);
		return viewErrorPage(HttpStatus.valueOf(code));
	}
	
	private String viewErrorPage(HttpStatus status) {
		return "error/" + status.value();
	}
}
